package cn.driver.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.driver.domain.Student;
import cn.driver.domain.Teacher;
import cn.driver.domain.User;
import cn.driver.mapper.TeacherMapper;
import cn.driver.utils.MD5Util;
import cn.driver.utils.MyException;

@Service
public class TeacherService {
	@Autowired
	private TeacherMapper teacherMapper;
	
	/**
	 * 注册用户
	 * @param username
	 * @param password
	 */
	public void regist(String name,String id,String phone,Integer age,String gender) throws MyException {
		//校验学员是否被注册
		Teacher s=teacherMapper.selectStudent(id);
		if(s!=null){
			throw new MyException("该用户已注册！请勿重复注册");
		}
		//MD5加密
		
		teacherMapper.registStudent(name,id, phone, age, gender);
	}
	/**
	 * 遍历学员
	 * @return
	 */
	public List<Teacher> studentInfo() {
		// TODO Auto-generated method stub
		return teacherMapper.studentInfo();
	}
	/**
	 * 模糊查询
	 * @param searchInfo
	 * @return
	 */
	public List<Teacher> stuSearch(String Info) {
		// TODO Auto-generated method stub
		return teacherMapper.searchInfo(Info);
	}
	/**
	 * 删除学员
	 * @param id
	 * @throws MyException
	 */
	public void deleteStu(String id) throws MyException {
		teacherMapper.deleteStu(id);
	}
	/**
	 * 查询用户
	 * @param id
	 * @return
	 */
	public Teacher selectStudent(String id) {
		// TODO Auto-generated method stub
		return teacherMapper.selectStudent(id);
	}
	/**
	 * 修改学员
	 * @param info
	 * @param name
	 * @param id
	 * @param teacher
	 * @param schedule
	 * @param phone
	 * @param age
	 * @param addr
	 * @param gender
	 */
	public void updateStu(String info,String name, String id, String phone, Integer age,
			 String gender) {
		teacherMapper.updateStu(info,name,id,phone, age, gender);

	}
}
